# -*- coding: utf-8 -*-

def justify_stop_words(char):
    
	
    # ==============================================
    # Aim: justify whether a char is useful or useless
    # Input : char
    # Output: True (stopword) / False (not stopword)
    # ===============================================
    
    STOP_WORDS = [u'【',u'】',u'[',u']',
              u'{',u'}',
              u'(',u')',u'（',u'）',
              u'？',u' ?',
              u';',u'；',
              u'》',u'《',u'<',u'>',
              u'，',u',', u'.',u'。',
              u'“',u'”',u'\'',
              u'「',u'」',
              u'! ',u'！',u'! ',
              u'/',u'\'',u'、',
              u'|',u'｜',
              u':',u'：',
              u'-',u'_',u'—',
              u'+',u'=',u'*',
              u'$',u'#',u'@',u'%',u'^',u'&',
              u'→',
              u'网'] # punctuations and useless characters
    
    if char in STOP_WORDS:
        return True
    elif char >= '\u4e00' and char <= '\u9fa5': # Chinese character
        return False
    elif char >= '0' and char <= '10': # numbers
        return True
    elif (char >= 'a' and char <= 'z') or (char >= 'A' and char <= 'Z'): # english characters
        return True
    else:
        return False
class StopWords:

    words = set()

    def __init__(self, filename="Data/stopword.txt"):
        #f = open(filename,"r",encoding="utf-8")
        f = open(filename, "r")
        for w in f.readlines():
            self.words.add(w[:-1])
        f.close()
        pass

    def filterSet(self,_words=set()):
        return set(_words) - self.words

    def filterList(self,_words=[]):
        ret = []
        for w in _words:
            if w not in self.words:
                ret.append(w)
        return ret




if __name__ == "__main__":
    import os
    os.chdir("..")

    words = ['is','fffd',',','!','rrrff']
    sw  = StopWords()
    print(sw.filterSet(words))
